package com.snail.controller;

import com.snail.model.dto.cart.OrderSubmitDTO;
import com.snail.model.pojo.cart.BizOrder;
import com.snail.result.PageResult;
import com.snail.result.Result;
import com.snail.service.BizOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class BizOrderController {
    @Autowired
    private BizOrderService bizOrderService;
    //创建订单
    @PostMapping("/createOrder")
    public Result createOrder(@RequestBody OrderSubmitDTO submitDTO) {
        bizOrderService.createOrder(submitDTO);
        return Result.success();
    }
    //根据用户id查询订单
    @GetMapping("/selectByUserId")
    public Result selectByUserId(BizOrder bizOrder, Integer pageNum, Integer pageSize) {
        PageResult<BizOrder> pageResult = bizOrderService.selectByUserId(bizOrder, pageNum, pageSize);
        return Result.success(pageResult);
    }
}
